//package com.sqx.modules.utils.typeHandler;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.sqx.modules.recovery.entity.GoodsSpecifications;
//import org.apache.ibatis.type.BaseTypeHandler;
//import org.apache.ibatis.type.JdbcType;
//import org.apache.ibatis.type.MappedJdbcTypes;
//import org.apache.ibatis.type.MappedTypes;
//
//import java.sql.CallableStatement;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.util.List;
//
///**
// * @description：TODO
// * @author： qiao
// * @create： 2024/10/15 15:31
// */
//@MappedTypes(List.class)
//@MappedJdbcTypes(JdbcType.VARCHAR)
//public class AttributeValueListTypeHandler extends BaseTypeHandler<List<GoodsSpecifications.AttributeValue>> {
//    @Override
//    public void setNonNullParameter(PreparedStatement ps, int i, List<GoodsSpecifications.AttributeValue> parameter, JdbcType jdbcType) throws SQLException {
//        ObjectMapper objectMapper = new ObjectMapper();
//        try {
//            String json = objectMapper.writeValueAsString(parameter);
//            ps.setString(i, json);
//        } catch (Exception e) {
//            throw new SQLException("Error setting parameter: " + e.getMessage(), e);
//        }
//    }
//
//    @Override
//    public List<GoodsSpecifications.AttributeValue> getNullableResult(ResultSet rs, String columnName) throws SQLException {
//        ObjectMapper objectMapper = new ObjectMapper();
//        try {
//            String json = rs.getString(columnName);
//            return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, GoodsSpecifications.AttributeValue.class));
//        } catch (Exception e) {
//            throw new SQLException("Error getting result: " + e.getMessage(), e);
//        }
//    }
//
//    @Override
//    public List<GoodsSpecifications.AttributeValue> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
//        ObjectMapper objectMapper = new ObjectMapper();
//        try {
//            String json = rs.getString(columnIndex);
//            return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, GoodsSpecifications.AttributeValue.class));
//        } catch (Exception e) {
//            throw new SQLException("Error getting result: " + e.getMessage(), e);
//        }
//    }
//
//    @Override
//    public List<GoodsSpecifications.AttributeValue> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
//        ObjectMapper objectMapper = new ObjectMapper();
//        try {
//            String json = cs.getString(columnIndex);
//            return objectMapper.readValue(json, objectMapper.getTypeFactory().constructCollectionType(List.class, GoodsSpecifications.AttributeValue.class));
//        } catch (Exception e) {
//            throw new SQLException("Error getting result: " + e.getMessage(), e);
//        }
//    }
//}
